<!--
 * @Author: your name
 * @Date: 2020-02-25 13:32:39
 * @LastEditTime: 2020-03-19 13:47:30
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \福路德扫码系统\html\cksm.html
 -->
<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0,viewport-fit=cover" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>Hello APP</title>
	<link rel="stylesheet" type="text/css" href="../css/vant.css">
	<link rel="stylesheet" type="text/css" href="../css/base.css" />
	<link rel="stylesheet" type="text/css" href="../css/local.css" />
	<script type="text/javascript" src="../script/jquery.js"></script>
	<script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
	<script type="text/javascript" src="../script/vue.min.js"></script>
	<script type="text/javascript" src="../script/vant.min.js"></script>

	<script type="text/javascript" src="../script/fastclick.js"></script>
	<script type="text/javascript" src="../script/base.js"></script>
	<script type="text/javascript" src="../script/app-tree.js"></script>
	<script type="text/javascript" src="../script/echarts.js"></script>

	<style type="text/css">
		.part {
			padding: 15px 15px 0 15px;
		}

		.part .pf {
			border-radius: 6px;
			box-shadow: 0px 1px 5px rgb(200, 198, 198);
			background-color: #fff;
			overflow: hidden;
		}

		.textarea {
			display: block;
		}

		.label {
			padding: 10px 16px;
		}

		.ap-f {
			border-bottom: 1px solid #f7f7f7;
		}

		.f-r {
			/* padding: 17px 0; */
		}

		.mark {
			padding: 17px 15px;
		}

		.mark1 {
			padding: 17px 5px 17px 15px;
			position: relative;
		}

		.f-sub {
			color: #969799;
			font-size: 13px;
			margin-top: 4px;
		}

		.line {
			position: relative;
			width: 30px;
		}

		.line1 {
			width: 60px;
		}

		.line-sq {
			display: inline-block;
			width: 11px;
			height: 11px;
			border-radius: 6px;
			background: #d6d6d6;
			position: absolute;
			left: 0;
			top: 12px;
		}

		.line-li {
			display: inline-block;
			width: 1px;
			background: #d6d6d6;
			position: absolute;
			left: 5px;
			top: -17px;
			bottom: -17px;
		}

		.line-li1 {
			display: inline-block;
			background: #d6d6d6;
			position: absolute;
			top: 52px;
			left: 35px;
			width: 3px;
			bottom: 10px;
		}

		.pd {
			padding: 16px 0;
		}

		.ap-r {
			text-align: right;
			padding-right: 10px;
			/* margin: -8px 0; */
			padding-top: 10px;
		}

		.ap-d {
			text-align: right;
			padding-right: 10px;
			color: #ccccce;
			font-size: 13px;
			float: right;
			padding-top: 3px;
		}

		.img {
			width: 34px;
			height: 34px;
			line-height: 34px;
			text-align: center;
			font-size: 12px;
			color: #fff;
			background-color: #3396fb;
			border-radius: 6px;
			margin: 0 auto;
			position: relative;
			user-select: none;
		}

		.img1 {
			width: 44px;
			height: 44px;
			line-height: 44px;
			text-align: center;
			font-size: 13px;
			color: #fff;
			background-color: #3396fb;
			border-radius: 6px;
			position: relative;
			user-select: none;
		}

		.dis-ib {
			display: inline-block;
			vertical-align: middle;
			text-align: center;
			min-width: 40px;
		}

		.dis2-ib {
			display: inline-block;
			vertical-align: middle;
			padding-bottom: 3px;
			text-align: center;
		}

		.dis3-ib {
			display: inline-block;
			margin: 0 6px;
			color: #969799;
			vertical-align: top;
			padding-top: 7px;
			text-align: center;
		}

		.ap-n {
			padding-top: 2px;
			font-size: 13px;
			color: #969799;
			text-align: center;
		}

		.bottom {
			padding: 8px 15px;
		}

		.part-white {
			padding: 15px;
			background-color: #fff;
			position: relative;
		}

		.title {
			line-height: 40px;
			font-size: 18px;
		}

		.title-sub {
			color: #aaacac;
			font-size: 13px;
		}

		.title-read {
			color: #3396fb;
			font-size: 13px;

		}

		.title-unread {
			color: #788a8a;
			font-size: 13px;
		}

		.ap-res {
			color: #a3a3a3;
			font-size: 15px;
			padding-top: 6px;
		}

		.ap-res1 {
			color: #c31616;
			font-size: 15px;
			padding-top: 6px;
		}

		.ap-img {
			position: absolute;
			right: 20px;
			bottom: -38px;
			width: 88px;
			opacity: 0.4;
		}

		.form-row {
			padding: 4px 16px;
		}

		.form-label {
			color: #808991;
			font-size: 13px;
			user-select: none;
		}

		.form-content {
			padding-top: 5px;
		}

		.npd {
			padding-top: 0;
			overflow-x: auto;
		}

		.pl {
			color: #969799;
			font-size: 16px;
			margin: 6px 2px 18px 0;
			min-height: 25px;
			border-bottom: 1px solid #ebedf0;
		}

		.sf {
			width: 16px;
			background: #fff;
			padding: 2px;
			border-radius: 8px;
			position: absolute;
			right: -5px;
			bottom: -2px;
		}

		.select {
			color: #3396fb;
			float: right;
			font-size: 13px;
			padding-top: 3px;
			vertical-align: middle;
		}

		.select a {
			vertical-align: middle;
		}

		.select img {
			width: 16px;
			vertical-align: middle;
		}

		.hq {
			padding: 10px 10px 0 0;
		}

		.wh {

			white-space: nowrap;
			overflow-x: auto;
			padding-right: 10px;
		}

		.plpd {
			padding-bottom: 5px;
		}

		.pictitle {
			line-height: 24px;
			color: #646566;
			user-select: none;
		}

		.piccontent {
			padding-top: 10px;
			overflow: hidden;
		}

		.van-uploader__preview {
			margin-right: 15px;
		}

		.no {
			text-align: center;
			color: #808991;
			font-size: 14px;
		}

		.li1 {
			top: 15px;
		}

		.li2 {
			bottom: 24px;
		}

		.da-c {
			color: #c31616;
		}

		.danger .van-field__control {
			color: #c31616;
		}

		.danger .van-field__label {
			color: #808991;
		}

		.ac-1 {
			color: #03b553;
		}

		.ac-2 {
			color: #c31616;
		}

		.checkbox {
			padding: 25px 5px 10px 10px;
		}

		.jl-remark {
			padding: 5px 0;
			color: #3396fb;
		}

		.memo-l {
			border-bottom: 1px solid rgb(235, 237, 240);
			padding: 4px 0;
		}

		.memo-l:last-child {
			border-bottom: 0;
		}

		.head {
			padding: 5px 10px;
		}

		.head .van-tag {
			padding: 4px 6px;
			size: 16px;
			margin: 2px;
		}

		.van-badge {
			margin: 10px 10px;
			background-color: #1989fa;
			color: #fff;
			display: block;
			width: 22px;
			padding: 3px;
			float: left;
			vertical-align: middle;
		}

		.pftitle {
			line-height: 40px;
		}

		.bottom-search {
			padding-bottom: 10px;
		}

		.bottom-search .van-cell--borderless::after,
		.van-cell:last-child::after {
			display: block;
		}

		.finishStatus {
			width: 60px;
			float: right;
		}

		.module {
			padding: 8px 10px 0 10px;
		}

		.module>div {
			background: #fff;
			padding: 8px;
			border-radius: 8px;
			overflow: hidden;
		}

		.chart {
			height: 250px;
			margin: 0 -8px;
		}

		.add {
			position: fixed;
			bottom: 80px;
			right: 20px;
			width: 40px;
			height: 40px;
			border-radius: 40px;
			text-align: center;
			line-height: 44px;
			background: #83bff6;
			opacity: .7;
			color: #fff;
			font-size: 20px;
		}

		/* 新增回复弹窗 */

		.pop_addReply {
			display: flex;
			flex-direction: column;
		}

		.pop_addReply .title {
			position: relative;
			top: 0;
			left: 0;
			display: flex;
			justify-content: center;
			align-items: center;
			background-color: #f7f7f7;
			border-bottom: 1px solid #83bff6;
			height: 50px;
			font-size: 16px;
			font-weight: 500;
		}

		.pop_addReply .content {
			display: flex;
			flex-direction: column;
			flex: 1;
			max-height: 350px;
			padding: 20px 10px;
			overflow: auto;
		}

		.pop_addReply .bottom {
			position: relative;
			left: 0;
			bottom: 0;
			display: flex;
			height: 50px;
			border-top: 1px solid #83bff6;
			justify-content: space-around;
		}

		.pop_addReply .van-field__label {
			width: 72px;
		}

		/* 新增回复弹窗 */

		/* 回复列表 */
		.replyWrap {
			display: flex;
			flex-direction: column;
			/* max-height: 266px; */
			/* overflow: auto; */
		}

		.replyWrap .titleName {
			display: flex;
			justify-content: center;
			align-items: center;
			font-weight: 600;
			color: #646566;
		}

		.replyWrap .replyContent {
			display: flex;
			justify-content: center;
			align-items: center;
			border-top: 1px dashed #a3a3a3;
			margin-top: 5px;
			border-bottom: 1px dashed #a3a3a3;
			margin-top: 5px;
			justify-content: center;
			align-items: center;
		}

		.replyWrap .replyContent .seq {
			padding-left: 5px;
			padding-right: 5px;
			font-size: 18px;
			font-weight: 500;
			color: #8ab2b7;
			text-align: center;
			width: 15px;
			text-shadow: 1px 2px 2px rgba(0, 0, 0, .52);
		}

		/* 回复列表 */

		.replyContent .van-field__label {
			width: 60px;
		}

		.replyBtnWrap {
			display: flex;
			justify-content: space-around;
			align-items: center;
			column-gap: 5px;
			padding: 5px;
		}

		.zrbm .van-field__label {
			width: 60px;
			/* background-color: #03b553; */
		}
	</style>
</head>

<body>
	<div id="app" v-cloak>
		<div class="box">

			<van-nav-bar-main title="零件质量问题汇总" left-arrow @click-left="onClickLeft">
				<div slot="right">
					<span @click="openSearch" style="margin-right:5px;">
						<van-icon name="search" size="18px"></van-icon>
					</span>
					<van-switch v-model="isList" size="18px" @change="changeList()" />
				</div>
			</van-nav-bar-main>

			<div class="content" style="padding-bottom: 20px;">
				<!-- <div class="head">
					<van-tag plain type="primary">
						未读消息数：{{unReadNum}}
					</van-tag>
				</div> -->
				<div class="head">
					<van-tag size="large" :color="form.className==item.parentClass ? '#5A78F5' : '#9CADF8'" round
						v-for="item in totalClass" @click="clickClass(item)">{{
						item.parentClass+item.unReadCount.toString()+'/'+item.readCount.toString() }}</van-tag>
				</div>
				<div class="head" v-if="form.className">
					<van-tag :color="form.pStatus==item.value ? '#B5D481' : '#D1E4B2'" round
						v-for="item in statusConfig" @click="clickStatus(item)">{{item.name}}
					</van-tag>
				</div>
				<div class="head" v-if="form.className">
					<van-tag :color="form.priority==item.name ? '#ffcc00' : '#ffe59e'" round v-for="item in issueConig"
						@click="clickIssue(item)">{{item.name}}
					</van-tag>
				</div>
				<div v-if="isList" class="content"
					style="padding:5px;display:flex;overflow:auto;flex-grow: 1;height:100%;width:100%;flex-direction: column;">
					<van-list v-model="listLoading" :finished="listFinished" finished-text="" @load="listOnLoad">
						<div class="part">
							<div class="pf" v-for="(item,index) in dataList">
								<div class="pftitle">
									<div class="van-badge">{{ index+1 }}</div>
									{{item.ProductName}}
									<van-tag v-if="!item.IsRead" type="danger" size="medium" style="float:right">未读
									</van-tag>
									<van-tag v-else type="success" size="medium" style="float:right">已读</van-tag>
								</div>
								<van-field label="日期" v-model="item.CkTime" readonly></van-field>
								<van-field label="发生地" v-model="item.Range" readonly></van-field>
								<!-- <van-field label="项目" v-model="item.Program" readonly></van-field> -->
								<van-field label="问题等级" v-model="item.priority" readonly></van-field>
								<van-field label="问题类型" v-model="item.ProblemType" readonly></van-field>
								<van-field label="问题描述" v-model="item.ProblemDesc2" readonly autosize type="textarea">
								</van-field>
								<van-field name="uploader" label="图片">
									<template #input>
										<van-uploader v-model="item.img" disabled :deletable="false" />
									</template>
								</van-field>
								<van-field v-if="item.audioUrl" label="音频描述" right-icon="../image/voiceOn.png"
									@click-right-icon="playAudio(item.audioUrl)" readonly></van-field>
								<van-row>
									<van-col span="12">
										<div class="zrbm">
											<van-field label="出现次数" v-model="item.RepeatCount" readonly></van-field>
										</div>
									</van-col>
									<van-col span="12">
										<div class="zrbm">
											<van-field label="投诉客户" v-model="item.ClientName" readonly></van-field>
										</div>
									</van-col>
								</van-row>

								<van-row>
									<van-col span="12">
										<div class="zrbm">
											<van-field label="制造部门" v-model="item.ParentClass" readonly></van-field>
										</div>
									</van-col>

									<van-col span="12">
										<div class="zrbm">
											<van-field label="流出部门" v-model="item.ParentClass2" readonly></van-field>
										</div>
									</van-col>
								</van-row>

								<van-field label="问题联系工程师" v-model="item.QualityEngineer" readonly></van-field>
								<!-- <van-field label="国内外" v-model="item.Range" readonly></van-field> -->

								<!-- <div class="form-row" v-if="form.remark">
									<div class="form-label">备注</div>
									<div class="form-content">{{form.remark}}</div>
								</div> -->
								<van-field v-if="item.Measure" type="textarea" label="临时措施" v-model="item.Measure"
									rows="2" autosize readonly>
								</van-field>
								<van-field v-if="item.SecMeasure" type="textarea" label="长期措施" v-model="item.SecMeasure"
									rows="2" autosize readonly>
								</van-field>
								<van-field v-if="item.Track" type="textarea" label="品质确认" v-model="item.Track" rows="2"
									autosize readonly>
								</van-field>
								<div class="replyBtnWrap">
									<van-button block color="#ffc000" text="查看历史问题" @click="checkHisProblem(item)">
									</van-button>
								</div>
								<div class="replyBtnWrap">
									<van-button color="#1e747c" size="small" text="制造部回复" @click="addReply(item,1)">
									</van-button>
									<van-button color="#1e747c" size="small" text="品质部确认" @click="addPzqr(item,1)">
									</van-button>
									<van-button color="#365a98" size="small" text="流出部回复" @click="addReply(item,2)">
									</van-button>
									<van-button color="#365a98" size="small" text="品质部确认" @click="addPzqr(item,2)">
									</van-button>
								</div>

								<!-- <van-row>
									<van-col span="24">
										<div class="replyBtnWrap">
											<van-button block color="#a2a8bb" size="small" text="查看历史问题"
												@click="checkHisProblem(item)"></van-button>
										</div>
									</van-col>
								</van-row> -->

								<!-- <van-row type="flex" justify="center">
									<van-col span="6">
										<div class="replyBtnWrap">
											<van-button type="info" size="small" text="制造回复" @click="addReply(item,1)">
											</van-button>
										</div>
									</van-col>
									<van-col span="6">
										<div class="replyBtnWrap">
											<van-button type="info" size="small" text="品质部确认" @click="addPzqr(item,1)">
											</van-button>
										</div>
									</van-col>
									<van-col span="6">
										<div class="replyBtnWrap">
											<van-button type="primary" size="small" text="流出回复"
												@click="addReply(item,2)">
											</van-button>
										</div>
									</van-col>
									<van-col span="6">
										<div class="replyBtnWrap">
											<van-button type="primary" size="small" text="品质部确认"
												@click="addPzqr(item,2)">
											</van-button>
										</div>
									</van-col>
								</van-row> -->

							</div>
						</div>
					</van-list>

				</div>

				<div v-else class="content"
					style="padding:5px;display:flex;overflow:auto;flex-grow: 1;height:100%;width:100%;flex-direction: column;">
					<div class="module">
						<div>
							<div class="label flex-box">
								<div class="squ"></div>
								<div class="flex-main">各部门质量问题汇总</div>
							</div>
							<div class="chart" id="chart1">

							</div>
							<div class="label flex-box">
								<div class="squ"></div>
								<div class="flex-main">产品质量问题汇总</div>
							</div>
							<div class="chart" style="height:300px" id="chart2">

							</div>
						</div>

					</div>
				</div>

				<div class="add" @click="upNewProblem">
					<van-icon name="plus"></van-icon>
				</div>

			</div>
		</div>

		<!-- 弹窗推荐位置 -->
		<van-popup v-model="showSearch" position="bottom">
			<div class="bottom-search">
				<van-col span="24">
					<van-field readonly v-model="form.beginTime" label="开始时间" right-icon="arrow"
						@click="openDate('beginTime')">
					</van-field>
				</van-col>
				<van-col span="24">
					<van-field readonly v-model="form.endTime" label="结束时间" right-icon="arrow"
						@click="openDate('endTime')">
					</van-field>
				</van-col>
				<van-col span="24">
					<van-field v-model="form.productName" label="产品名称" placeholder="请输入...">
					</van-field>
				</van-col>
				<van-col span="24">
					<van-field readonly v-model="form.range" label="国内外" placeholder="请选择" @click="openSelect">
					</van-field>
				</van-col>
				<van-col span="24">
					<van-field readonly v-model="form.className" label="部门" placeholder="请选择" @click="openSelect2">
					</van-field>
				</van-col>


			</div>
			<div class="btn-padding">
				<van-button color="#83bff6" type="primary" block style="border-radius: 0;" @click="searchData">
					查询
				</van-button>
			</div>
		</van-popup>
		<van-popup v-model="showDate" position="bottom">
			<van-datetime-picker v-model="currentDate" type="date" @confirm="confirmDate" @cancel="cancelDate"
				cancel-button-text="取消" />
		</van-popup>
		<van-popup v-model="showDate2" position="bottom">
			<van-datetime-picker v-model="currentDate" type="date" @confirm="confirmDate2" @cancel="cancelDate2"
				cancel-button-text="取消" />
		</van-popup>
		<van-popup v-model="showSelect" position="bottom">
			<van-picker show-toolbar :columns="rangeList" @confirm="confirmSelect" @cancel="cancelSelect">
			</van-picker>
		</van-popup>
		<van-popup v-model="showSelect2" position="bottom">
			<van-picker show-toolbar :columns="classList" @confirm="confirmSelect2" @cancel="cancelSelect2">
			</van-picker>
		</van-popup>

		<!-- 零件质量问题回复提交弹窗 -->
		<van-popup v-model="showAddReply" position="bottom" safe-area-inset-bottom round>
			<div class="pop_addReply">
				<div class="title">{{replyPopTitle}}</div>
				<div class="content">
					<van-row>
						<!-- 回复人员/部门 -->
						<van-col span="12">
							<van-field v-model="replyContent.ClassName" label="回复部门" colon readonly></van-field>
						</van-col>
						<van-col span="12">
							<van-field v-model="replyContent.UserName" label="回复人员" colon readonly></van-field>
						</van-col>
						<!-- 临时/长期措施 -->
						<van-col span="24" v-if="!isPZQR">
							<van-field v-model="replyContent.tms" label="临时措施" type="textarea" autosize rows="2"
								placeholder="请输入临时措施" colon clearable>
							</van-field>
						</van-col>
						<van-col span="24" v-if="!isPZQR">
							<van-field v-model="replyContent.lms" label="长期措施" type="textarea" autosize rows="2"
								placeholder="请输入长期措施" colon clearable>
							</van-field>
						</van-col>
						<!-- 预计完成时间是否可估 -->
						<van-cell v-if="!isPZQR" center title="整改时间可估">
							<template #right-icon>
								<van-checkbox v-model="replyContent.hasPreTime" shape="square" @change="canEstimated">
								</van-checkbox>
							</template>
						</van-cell>
						<van-field v-if="!isPZQR && replyContent.hasPreTime" v-model="replyContent.preTime"
							label="预计整改完成时间" placeholder="请选择预计整改完成时间" readonly is-link @click="openDate2">
						</van-field>

						<!-- 品质部人员可填写 -->
						<van-cell v-if="isPZQR" center title="是否整改完成">
							<template #right-icon>
								<van-checkbox v-model="replyContent.isDone" shape="square" @change="isDone">
								</van-checkbox>
							</template>
						</van-cell>
						<van-field v-if="isPZQR" v-model="replyContent.pzqr" label="品质部确认" placeholder="请输入确认内容" colon
							clearable>
						</van-field>
					</van-row>
				</div>
				<div class="bottom">
					<van-button type="default" text="取消" size="small" @click="cancelReply" block>
					</van-button>
					<van-button type="info" text="确认" size="small" @click="confirmReply" style="margin-left: 15px;"
						block>
					</van-button>
				</div>
			</div>
		</van-popup>
		<!-- 弹窗推荐位置 -->

	</div>
</body>
<script type="text/javascript">
	var vm;
	var myChart1 = null, myChart2 = null;

	apiready = function () {
		var UIAlbumBrowser = api.require('UIAlbumBrowser');
		var photoBrowser = api.require('photoBrowser');
		var audioStreamer = api.require('audioStreamer');
		var isPlay = false;
		var isOpenImg = false;
		var approvalConfigdata = '';
		var allCurrentApprovalIDs = [];
		var QualityCkID = 0;


		api.addEventListener({
			name: 'keyback'
		}, function (ret, err) {
			if (!isOpenImg) {
				vm.onClickLeft();
			} else {
				photoBrowser.close();
			}

		});

		audioStreamer.addEventListener({
		}, function (ret) {
			// alert(ret.state);
			if (ret.state == 'finished') {
				isPlay = false;
				console.log('播放完成')
			}
		});


		vm = new Vue({
			el: '#app',
			data: {
				showPopover: false,
				// 通过 actions 属性来定义菜单选项
				actions: [{ text: '选项一' }, { text: '选项二' }, { text: '选项三' }],
				showSearch: false,
				listLoading: false,
				listFinished: true,
				pageIndex: 1,
				pageSize: 2,	//modified by fy 2022.4.13 调小每页记录数 配合未读消息
				currentDate: new Date(),
				queryTimeStr: '',
				showDate: false,
				showDate2: false,
				showSelect: false,
				showSelect2: false,
				totalCount: 0,
				dataList: [],
				form: {
					beginTime: '',
					endTime: '',
					productName: '',
					range: '',
					className: '',
					pStatus: 0,
					priority: ''
				},
				rangeList: [
					'内部', '国内', '国外'
				],
				classList: [
					'龙门线', '品质', '技术', '仓库', '喷漆', '三线', '商务', '注塑', '包装'
				],
				totalClass: [],
				totalProduct: [],
				isList: true,
				unReadNum: 0,	//未读消息数量
				serverIP: 'http://' + APP.serverIP(),
				userInfo: APP.getUserInfo(),
				showAddReply: false,
				isPZQR: false,
				replyPopTitle: '新增回复',
				replyContent: {
					Option: 0,	// 1.新增回复 2.品质确认
					QualityReplyID: 0,
					QualityCkID: 0,
					ClassID: 0,
					ClassName: '',
					UserID: 0,
					UserName: '',
					tms: '',
					tmsTime: '',
					lms: '',
					lmsTime: '',
					hasPreTime: 0,
					preTime: '',
					pzqr: '',
					replyType: 0,	// 回复类型 1: 制造责任部门 2: 流出责任部门
					isDone: 0	// 整改是否完成
				},	//回复内容
				statusConfig: [
					{ name: '无临时措施', value: 1 },
					{ name: '无长期措施', value: 2 },
					{ name: '未整改完成', value: 3 }
				],
				issueConig: [
					{ name: '一级问题' },
					{ name: '二级问题' },
					{ name: '三级问题' }
				]
			},
			created: function () {
				var that = this;

				// if (APP.getUserInfo().UserID == 19 || APP.getUserInfo().UserID == 35 || APP.getUserInfo().UserID == 33) {
				// 	that.editRemark = true;
				// }
				that.getDataList(1);
			},
			methods: {

				// 整改完成时间是否可估
				canEstimated(isChecked) {
					if (isChecked) {
						vm.replyContent.hasPreTime = 1;
					} else {
						vm.replyContent.hasPreTime = 0;
						vm.replyContent.preTime = '';
					}
				},

				// 整改是否完成
				isDone(isChecked) {
					if (isChecked) {
						vm.replyContent.isDone = 1;
						vm.replyContent.pzqr = '整改完成';
					} else {
						vm.replyContent.isDone = 0;
						vm.replyContent.pzqr = '';
					}
				},

				openSearch: function () {
					var that = this;
					that.showSearch = true;
				},

				openDate: function (objStr) {
					var that = this;
					that.queryTimeStr = objStr;

					if (that.form[that.queryTimeStr]) {
						that.currentDate = new Date(that.form[that.queryTimeStr]);
					} else {
						that.currentDate = new Date();
					}

					that.showDate = true;

				},

				openDate2() {
					console.log(11)
					var that = this;
					if (that.replyContent.preTime) {
						that.currentDate = new Date(that.replyContent.preTime);
					} else {
						that.currentDate = new Date();
					}
					that.showDate2 = true;
				},

				confirmDate: function (value) {
					var that = this;
					that.form[that.queryTimeStr] = APP.getFormatDate(value).split(' ')[0];

					that.showDate = false;
				},

				confirmDate2(value) {
					var that = this;
					that.replyContent.preTime = APP.getFormatDate(value).split(' ')[0];
					that.showDate2 = false;
				},

				cancelDate: function (value) {
					var that = this;
					that.form[that.queryTimeStr] = '';
					that.showDate = false;
				},

				cancelDate2(value) {
					var that = this;
					that.replyContent.preTime = '';
					that.showDate2 = false;
				},

				searchData: function () {
					var that = this;
					that.showSearch = false;
					that.isList = true;
					that.getDataList(1);
				},
				getDataList: function (pageIndex) {
					var that = this;
					that.showLoading = true;
					that.pageIndex = pageIndex;
					if (pageIndex == 1) {
						that.dataList = [];
					}
					APP.ajax('qualityPageRpt', {
						pageIndex: that.pageIndex,
						pageSize: that.pageSize,
						productName: that.form.productName,
						beginTime: that.form.beginTime,
						endTime: that.form.endTime,
						range: that.form.range,
						className: that.form.className,
						pStatus: that.form.pStatus,
						priority: that.form.priority
					}, function (data) {

						vm.totalClass = data.ds2;
						vm.totalProduct = data.ds3;
						vm.unReadNum = data.ds4[0].unReadNum;
						//vm.initChart();
						//console.log(JSON.stringfy(vm.totalCount))

						if (data.ds1.length > 0) {
							vm.totalCount = parseInt(data.ds1[0]['TotalCount']);
							if (vm.pageIndex * vm.pageSize >= vm.totalCount) {
								that.listFinished = true;
							}
							else {
								that.listFinished = false;
							}
						}
						if (data.ds.length > 0) {
							for (var i = 0; i < data.ds.length; i++) {
								if (data.ds[i]['ProblemImg']) {
									data.ds[i]['img'] = [{ url: 'http://' + APP.serverIP() + data.ds[i]['ProblemImg'] }];
								} else {
									data.ds[i]['img'] = [];
								}

								data.ds[i]['audioUrl'] = data.ds[i].ProblemAudio;	// '/upload/part_audio/speech_20240119093205.pcm';	//待替换路径
								if (data.ds[i].Measure)
									data.ds[i].Measure = data.ds[i].Measure.replace(/\|/g, '\n');
								else
									data.ds[i].Measure = '';

								if (data.ds[i].SecMeasure)
									data.ds[i].SecMeasure = data.ds[i].SecMeasure.replace(/\|/g, '\n');
								else
									data.ds[i].SecMeasure = '';

								if (data.ds[i].Track)
									data.ds[i].Track = data.ds[i].Track.replace(/\|/g, '\n');
								else
									data.ds[i].Track = '';
							}
							that.dataList = that.dataList.concat(data.ds);
							// console.log(JSON.stringify(that.dataList))
						}
						//  vm.updateReadStatus();	//更新已读状态
						that.listLoading = false;
						api.hideProgress();
					})
				},

				listOnLoad: function () {
					var that = this;
					//分页触发分页前更新上一页已读状态
					if (vm.dataList.length)
						vm.updateReadStatus();	//更新已读状态
					that.pageIndex++;
					// console.log(that.pageIndex)
					that.getDataList(that.pageIndex);
				},
				openSelect() {
					vm.showSelect = true;
				},
				openSelect2() {
					vm.showSelect2 = true;
				},
				confirmSelect: function (value, index) {
					var that = this;
					that.form.range = value;
					that.showSelect = false;
				},
				cancelSelect: function () {
					var that = this;
					that.form.range = '';
					that.showSelect = false;
				},
				confirmSelect2: function (value, index) {
					var that = this;
					that.form.className = value;
					that.showSelect2 = false;
				},
				cancelSelect2: function () {
					var that = this;
					that.form.className = '';
					that.showSelect2 = false;
				},
				clickClass(classObj) {
					vm.form.pStatus = 0;
					if (classObj.parentClass == vm.form.className) {
						vm.form.className = '';
					} else {
						vm.form.className = classObj.parentClass;
					}
					vm.getDataList(1);
				},
				clickStatus(statusObj) {
					if (vm.form.pStatus == statusObj.value) {
						vm.form.pStatus = 0;
					} else {
						vm.form.pStatus = statusObj.value;
					}
					vm.getDataList(1);
				},
				clickIssue(statusObj) {
					// console.log(JSON.stringify(statusObj))
					if (vm.form.priority == statusObj.name) {
						vm.form.priority = '';
					} else {
						vm.form.priority = statusObj.name;
					}
					vm.getDataList(1);
				},
				initChart() {
					var that = this;
					try {
						myChart1.clear();
					}
					catch (e) { }
					myChart1 = echarts.init(document.getElementById('chart1'));
					var seriesData = [];
					for (var i = 0; i < vm.totalClass.length; i++) {
						seriesData.push({
							name: vm.totalClass[i].parentClass,
							value: vm.totalClass[i].count
						})
					}
					var option1 = {
						grid: {
							top: 30,
							left: 50,
							right: 50,
							bottom: 30
						},
						series: [{
							data: seriesData,
							name: '问题数量',
							type: 'pie',
							label: {
								formatter: '{b}:{c}\n百分比:{d}%'
							},
						}]
					};
					myChart1.setOption(option1);
				},
				initChart2() {
					var that = this;
					myChart2 = echarts.init(document.getElementById('chart2'));
					var productData = [], countData = [];
					for (var i = 0; i < vm.totalProduct.length; i++) {
						productData.push(vm.totalProduct[i].ProductName);
						countData.push(vm.totalProduct[i].count);
					}
					var option1 = {
						grid: {
							top: 30,
							left: '10%',
							right: 50,
							bottom: '50%'
						},
						xAxis: {
							type: 'category',
							name: '产品名称',
							data: productData,
							axisLabel: {
								interval: 0,
								rotate: 40
							}
						},
						yAxis: [{
							type: 'value',
							name: '数量'
						}],
						series: [{
							data: countData,
							name: '产品名称',
							type: 'bar',
							label: {
								show: true
							}
						}]
					};
					myChart2.setOption(option1);
				},

				// 切换页面显示
				changeList() {
					if (!vm.isList) {
						setTimeout(function () {
							vm.initChart();
							vm.initChart2();
						}, 200);
					}
				},

				// 更新问题已读
				updateReadStatus() {
					var ckIds = [];
					for (var i = 0; i < vm.dataList.length; i++) {
						ckIds.push(vm.dataList[i].QualityCkID);
						vm.dataList[i].IsRead = true;	//设置为已读
					}
					var optIds = ckIds.join(',');	//需要更新的质量问题记录ID逗号隔开
					APP.ajax('updateQuantityRead', {
						ckIds: optIds
					}, function (data) { console.log(1) });
				},

				// 播放问题描述音频
				playAudio(audioUrl) {
					url = vm.serverIP + audioUrl;
					// console.log(url)
					if (isPlay) {
						audioStreamer.stop();
						isPlay = false;
					} else {
						isPlay = true;
						audioStreamer.setVolume({
							volume: 0.6
						});
						audioStreamer.onNormal();
						audioStreamer.openPlayer({
							path: url,
						}, function (ret) {

						});
					}
				},

				hasPreTime(value) {
					if (value) {
						vm.replyContent.hasPreTime = 1;
					} else {
						vm.replyContent.hasPreTime = 0;
						vm.replyContent.preTime = '';
					}
				},

				// 新增回复
				addReply(ckItem, replyType) {
					let preTitle = replyType == 1 ? '制造责任部门' : '流出责任部门';
					vm.replyPopTitle = preTitle + '-新增回复';
					vm.isPZQR = false;

					let classids = [];
					let classids2 = [];
					if (ckItem.ParentClassID != null) {
						ckItem.ParentClassID.split();	// 主要责任部门
					}
					if (ckItem.ParentClassID2 != null) {
						ckItem.ParentClassID2.split();	// 次要责任部门
					}

					let canReply = classids.some(item => item == vm.userInfo.ClassID);	// 是否可回主责
					let canReply2 = classids2.some(item => item == vm.userInfo.ClassID);	// 是否可回次责

					if ((!canReply && !canReply2) && vm.userInfo.UserID != 19) {
						// if (!canReply && !canReply2) {
						layer.open({
							content: '当前用户非责任部门人员,无法提交回复!',
							skin: 'msg',
							time: 2
						})
						return false;
					} else {
						// 默认带入当前用户信息
						vm.replyContent.QualityCkID = ckItem.QualityCkID;
						vm.replyContent.ClassID = vm.userInfo.ClassID;
						vm.replyContent.ClassName = vm.userInfo.ClassName;
						vm.replyContent.UserID = vm.userInfo.UserID;
						vm.replyContent.UserName = vm.userInfo.UserName;
						vm.replyContent.replyType = replyType;
					}
					vm.replyContent.Option = 1;	// 措施回复
					vm.showAddReply = true;
				},

				// 品质部确认
				addPzqr(ckItem, replyType) {
					let preTitle = replyType == 1 ? '制造责任部门' : '流出责任部门';
					vm.replyPopTitle = preTitle + '-品质部确认';
					vm.isPZQR = true;
					if (vm.userInfo.ClassID != 1022) {
						layer.open({
							content: '当前用户非品质部门人员,无法提交确认!',
							skin: 'msg',
							time: 2
						})
						return false;
					} else {
						// 默认带入当前用户信息
						vm.replyContent.QualityCkID = ckItem.QualityCkID;
						vm.replyContent.ClassID = vm.userInfo.ClassID;
						vm.replyContent.ClassName = vm.userInfo.ClassName;
						vm.replyContent.UserID = vm.userInfo.UserID;
						vm.replyContent.UserName = vm.userInfo.UserName;
						vm.replyContent.replyType = replyType;
					}

					vm.replyContent.Option = 2;	// 品质确认
					vm.showAddReply = true;
				},

				// 确认提交回复
				confirmReply() {

					APP.ajax('addQaReply', vm.replyContent, function (res) {
						vm.replyContent = {
							Option: 0,
							QualityReplyID: 0,
							QualityCkID: 0,
							ClassID: 0,
							ClassName: '',
							UserID: 0,
							UserName: '',
							tms: '',
							tmsTime: '',
							lms: '',
							lmsTime: '',
							hasPreTime: 0,
							preTime: '',
							pzqr: '',
							replyType: 0,
							isDone: 0
						}


						if (res.ds[0].status == 200) {
							if (res.ds1 && res.ds1.length) {
								let matchQaItem = vm.dataList.find(item => item.QualityCkID == res.ds1[0].QualityCkID);
								matchQaItem.Measure = res.ds1[0].Measure.replace(/\|/g, '\n');
								matchQaItem.SecMeasure = res.ds1[0].SecMeasure.replace(/\|/g, '\n');
								matchQaItem.Track = res.ds1[0].Track.replace(/\|/g, '\n');

								layer.open({
									content: '回复成功!',
									skin: 'msg',
									time: 2
								});
							}
						} else {
							layer.open({
								content: res.ds[0].msg,
								skin: 'msg',
								time: 2
							});
							return false;
						}
					})

					vm.showAddReply = false;
				},

				// 取消提交回复
				cancelReply() {
					// 清空回复内容
					vm.replyContent = {
						Option: 0,
						QualityReplyID: 0,
						QualityCkID: 0,
						ClassID: 0,
						ClassName: '',
						UserID: 0,
						UserName: '',
						tms: '',
						tmsTime: '',
						lms: '',
						lmsTime: '',
						hasPreTime: 0,
						preTime: '',
						pzqr: '',
						replyType: 0,
						isDone: 0
					}

					vm.showAddReply = false;
				},

				// 新增零件质量问题
				upNewProblem() {
					api.openWin({
						name: 'partProblem',
						url: 'partProblem.html'
					})
				},

				// 查看当前工序、当前零件历史问题
				checkHisProblem(item) {
					api.openWin({
						name: 'config/report',
						url: 'config/report.html',
						reload: true,
						slidBackEnabled: false,
						scaleEnabled: true,
						allowEdit: true,
						pageParam: {
							titleName: item.ProductName + '-历史问题清单',
							objName: '所有问题清单报表',
							tranPageText: 'landscape_left',
							Range: item.Range,
							ProductName: item.ProductName
						}
					})
				},

				onClickLeft() {
					api.closeWin();
				}

			}
		})
	};
</script>

</html>